package com.salary.system;

import java.time.LocalDate;

public class Manager extends Employee {
    private static final double MIN_PERFORMANCE = 0.5; // 最低绩效系数
    private static final double MAX_PERFORMANCE = 2.0; // 最高绩效系数
    private double monthlySalary; // 固定月薪
    private double baseBonus; // 基础奖金
    private double performanceCoeff; // 新增：绩效系数

    // 构造方法（参数校验）
    public Manager(String name, String empId, String department, LocalDate hireDate, double monthlySalary, double baseBonus, double performanceCoeff) {
        super(name, empId, department, hireDate);
        if (monthlySalary <= 0) {
            throw new IllegalParameterException("月薪必须大于0（当前：" + monthlySalary + "）");
        }
        if (baseBonus < 0) {
            throw new IllegalParameterException("基础奖金不能为负（当前：" + baseBonus + "）");
        }
        if (performanceCoeff < MIN_PERFORMANCE || performanceCoeff > MAX_PERFORMANCE) {
            throw new IllegalParameterException("绩效系数范围：" + MIN_PERFORMANCE + "-" + MAX_PERFORMANCE + "（当前：" + performanceCoeff + "）");
        }
        this.monthlySalary = monthlySalary;
        this.baseBonus = baseBonus;
        this.performanceCoeff = performanceCoeff;
    }

    // 优化：奖金 = 基础奖金 × 绩效系数
    @Override
    public double calculateSalary() {
        double bonus = baseBonus * performanceCoeff;
        return monthlySalary + bonus;
    }

    // Getter（JSON序列化用）
    public double getMonthlySalary() { return monthlySalary; }
    public double getBaseBonus() { return baseBonus; }
    public double getPerformanceCoeff() { return performanceCoeff; }
    public double getCalculateSalary() { return calculateSalary(); }
}